package ru.amse.tsyganov.jumleditor.commands;

import java.util.List;

import ru.amse.tsyganov.jumleditor.model.ActivityGraph;
import ru.amse.tsyganov.jumleditor.model.State;
import ru.amse.tsyganov.jumleditor.model.Transition;
import ru.amse.tsyganov.jumleditor.properties.Property;
import ru.amse.tsyganov.jumleditor.view.ConnectionPoint;
import ru.amse.tsyganov.jumleditor.view.representation.ActivityGraphView;
import ru.amse.tsyganov.jumleditor.view.representation.StateView;
import ru.amse.tsyganov.jumleditor.view.representation.TransitionView;

public class CommandFactory {
	
	public static Command createMoveStateCommand(
			StateView<? extends State> stateView,
			int moveToX, int moveToY) {
		
		return new MoveStateCommand(stateView, moveToX, moveToY, true);
	}
	
	public static Command createResizeStateCommand(
			StateView<? extends State> resizingState, 
			int moveToX, int moveToY, int newWidth, int newHeight) {
		
		return new ResizeStateCommand(resizingState, 
				moveToX, moveToY, newWidth, newHeight);
	}
	
	public static Command createNewStateCommand(
			ActivityGraphView<? extends ActivityGraph> activityGraphView,
			StateView<? extends State> stateView) {
		
		return new NewStateCommand(activityGraphView, stateView);
	}
	
	public static Command createDeleteStateCommand(
			ActivityGraphView<? extends ActivityGraph> activityGraphView,
			StateView<? extends State> stateView) {
		
		return new DeleteStateCommand(activityGraphView, stateView);
	}
	
	public static Command createNewTransitionCommand(
			TransitionView<Transition> transitionView) {
		
		return new NewTransitionCommand(transitionView);
	}
	
	public static <T extends Transition> Command createDeleteTransitionCommand(
			TransitionView<T> t) {
		
		return new DeleteTransitionCommand<T>(t);
	}
	
	public static Command createMoveTransitionCommand(
			TransitionView<? extends Transition> movingTransition, 
			ConnectionPoint newSourceConnectionPoint, 
			ConnectionPoint newTargetConnectionPoint) {
		
		return new MoveTransitionCommand(movingTransition, 
				newSourceConnectionPoint, newTargetConnectionPoint);
	}
	
	public static Command createCompositeCommand(
			List<? extends Command> commandList) {
		
		return new CompositeCommand(commandList);
	}
	
	public static Command createChangePropertyCommand(
			Property property, Object newValue) {
		
		return new ChangePropertyCommand(property, newValue);
	}
}
